<template>
  <section>
    <div class="feature-nav">
      <div
        v-for="(item, index) in navList"
        :key="index"
        class="nav-item"
        :class="{ active: item.active }"
        @click="handleSelect(index)"
        @mouseenter="handleSelect(index)"
      >
        <div class="nav-icon" :style="{ backgroundImage: `url(${item.icon})` }"></div>
        <span class="nav-text">{{ item.text }}</span>
      </div>
    </div>
    <div class="health-device">
      <div class="device-content">
        <div class="device-img">
          <img :src="navList[activeIndex].center.deviceImg" :alt="navList[activeIndex].center.title" />
        </div>
        <div class="device-info">
          <h3 class="device-title">{{ navList[activeIndex].center.title }}</h3>
          <h3 class="device-subtitle">{{ navList[activeIndex].center.subtitle }}</h3>

          <!-- eslint-disable-next-line vue/no-v-html -->
          <p class="device-desc" v-html="navList[activeIndex].center.description"></p>
          <div class="btn-success-glow download-btn" @click="openReport">立即下载</div>
        </div>
      </div>
    </div>
  </section>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { openExternalLink } from '@/utils/navigation.ts'

const activeIndex = ref(0)
const navList = ref([
  {
    text: '健康手环',
    active: true,
    icon: 'https://images.health.ufutx.com/202507/02/4aae244f94bbf8bf352e8ab8e2270a81.png',
    center: {
      navLabel: '健康手环', // 导航栏显示文字
      title: '健康手环', // 页面主标题
      subtitle: 'AI精准个性化健康方案服务', // 副标题
      description: '智能穿戴设备数据监测<br>健康手环 你的专属健康管家，智能体脂秤、精准计算身体状态', // 支持<br>换行
      deviceImg: 'https://images.health.ufutx.com/202506/23/c14a55da8a21ec3712d768cd052b7220.png' // 左侧设备图
    }
  },
  {
    text: '智能体脂秤',
    active: false,
    icon: 'https://images.health.ufutx.com/202506/23/0ed7ffaa2eb0116dd46b6f1597795766.png',
    center: {
      title: '智能体脂秤', // 页面主标题
      subtitle: 'AI精准计算身体状态', // 副标题
      description: '智能穿戴设备数据监测<br>健康手环 你的专属健康管家，智能体脂秤、精准计算身体状态', // 支持<br>换行
      deviceImg: 'https://images.health.ufutx.com/202506/23/13d992813c70c5674658581144a4c17f.png' // 左侧设备图
    }
  },
  {
    text: '商城',
    active: false,
    icon: 'https://images.health.ufutx.com/202506/23/0fcdeadda0440375eab9c27e67de79f7.png',
    center: {
      title: '自用商城', // 页面主标题
      subtitle: '品质生活 触手可得', // 副标题
      description: '拒绝虚假营销｜确保抄底入手<br>质量管控｜商家严选｜实物鉴别｜售后无忧', // 支持<br>换行
      deviceImg: 'https://images.health.ufutx.com/202506/23/4b87bf45e69411e4377929d38deb2d3f.png' // 左侧设备图
    }
  },
  {
    text: '个人成长',
    active: false,
    icon: 'https://images.health.ufutx.com/202506/23/3c527e6e644a46edc4164616d0b4dc3e.png',
    center: {
      title: '个人成长｜1分钟演讲', // 页面主标题
      subtitle: '提升自我 开口就是100分', // 副标题
      description: '模拟真实演讲场景<br>每日数据同步更行，你的努力时间都看得见！', // 支持<br>换行
      deviceImg: 'https://images.health.ufutx.com/202506/23/79605e4b83e27dfa3c701df8d1f3baa0.png' // 左侧设备图
    }
  },
  {
    text: '单身标签',
    active: false,
    icon: 'https://images.health.ufutx.com/202506/23/b42d943c5454dc8abfcbd098a7a07e92.png',
    center: {
      title: '单身标签', // 页面主标题
      subtitle: '爱的序幕由此拉开', // 副标题
      description: '单身徽章，单身身份之耀，社交吸睛磁石，引同频邂逅。', // 支持<br>换行
      deviceImg: 'https://images.health.ufutx.com/202506/23/1ac061f59d86088b7233b7b7d03de3a0.png' // 左侧设备图
    }
  }
])
// 外部链接跳转（新标签）
const openReport = () => {
  openExternalLink('https://sj.qq.com/appdetail/com.ufutx.lovehealth', '_blank')
}
const handleSelect = (index: number) => {
  activeIndex.value = index
  navList.value.forEach((item, i) => {
    item.active = i === index
  })
}
</script>

<style scoped lang="less">
@import '@/styles/global.less';

.feature-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 50px;
  padding-top: 50px;

  .nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    position: relative;

    &:not(:first-child)::before {
      content: '';
      position: absolute;
      left: -30px;
      top: 50%;
      transform: translateY(-50%);
      width: 1px;
      height: 12px;
      background-color: #cccccc;
    }

    .nav-icon {
      width: 22px;
      height: 22px;
      background-size: contain;
      background-repeat: no-repeat;
      background-position: center;
      //opacity: 0.8;
      transition: opacity 0.3s;
    }

    .nav-text {
      font-size: 20px;
      color: @text-color-secondary;
      transition: color 0.3s;
    }

    &.active {
      .nav-icon {
        opacity: 1;
      }
      .nav-text {
        color: #18ca6e;
        font-weight: bold;
      }
    }

    &:hover:not(.active) {
      .nav-icon {
        opacity: 0.8;
      }
      .nav-text {
        color: #666;
      }
    }
  }
}

.health-device {
  padding: 50px 192px 80px 192px;
  background: #fff;

  .section-divider {
    text-align: center;
    font-size: 50px;
    color: @text-color;
    font-weight: bold;
  }
  .device-content {
    display: flex;
    align-items: center;
    //justify-content: space-between;
    gap: 132px;

    .device-img {
      //flex: 1;
      //text-align: center;
      width: 900px;
      height: 716px;
      overflow: hidden;
      border-radius: 10px;
      img {
        width: 100%;
        background: #f6fffa;
      }
    }

    .device-info {
      flex: 1;
      text-align: left;

      .device-title {
        color: #18ca6e;
        font-size: 36px;
        font-style: normal;
        font-weight: 600;
        line-height: normal;
      }
      .device-subtitle {
        color: #0e0e0e;
        font-size: 36px;
        font-style: normal;
        font-weight: 600;
        line-height: normal;
      }
      .device-desc {
        color: var(--66676-c, #66676c);
        font-size: 20px;
        font-style: normal;
        font-weight: 400;
        line-height: 36px; /* 180% */
        text-transform: capitalize;
        .my(30px);
      }

      .download-btn {
        display: inline-block;
        padding: 14px 30px;
        align-items: center;
        gap: 20px;
        border-radius: 100px;
        border: 1px solid var(--18-ca-6-e, #18ca6e);
        background: #18ca6e;
        color: #fff;
        font-size: 20px;
      }
    }
  }

  @media (max-width: @tablet-breakpoint) {
    flex-direction: column;
    padding: 40px 20px;

    .device-content {
      flex-direction: column;
      text-align: center;

      .device-info {
        .device-desc {
          max-width: 100%;
          line-height: 12px;
        }
      }
    }
  }
}
/* 响应式适配 */
@media (max-width: @tablet-breakpoint) {
  .feature-nav {
    gap: 20px;
    .nav-item {
      &:not(:first-child)::before {
        left: -12px;
        height: 8px;
      }
      .nav-text {
        font-size: 10px;
      }
    }
  }
}
</style>
